#include "wa_ssd1306_spi_drv.h"
#include "wa_disp_drv.h"
#include "dev_ssd1306_spi.h"

void wa_ssd1306_spi_drv_setpixel(int32_t x, int32_t y, wa_gui_color color)
{
	if(color > 0x7f)
	{
		color = 1;
	}
	else
	{
		color = 0;
	}
	dev_ssd1306_spi_setpixel(x, y, (uint8_t)color);
}

wa_gui_color wa_ssd1306_spi_drv_getpixel(int32_t x, int32_t y)
{
	uint8_t temp;
	temp = dev_ssd1306_spi_getpixel(x, y);
	if(temp == 0)
	{
		return 0;
	}
	else
	{
		return 0xffffffff;
	}
}

void wa_ssd1306_spi_drv_fill(int32_t x, int32_t y, int32_t width, int32_t height, wa_gui_color color)
{
	if(color > 0x7f)
	{
		color = 1;
	}
	else
	{
		color = 0;
	}
	dev_ssd1306_spi_fill(x, y, width, height, (uint8_t)color);
}

void wa_ssd1306_spi_drv_clear(void)
{
	dev_ssd1306_spi_clear();
}

void wa_ssd1306_spi_drv_update(int32_t x, int32_t y, int32_t width, int32_t height)
{
	dev_ssd1306_spi_update(x, y, width, height);
}

void wa_ssd1306_spi_drv_init(void)
{
	wa_disp_drv_set_setpixel(wa_ssd1306_spi_drv_setpixel);
	wa_disp_drv_set_getpixel(wa_ssd1306_spi_drv_getpixel);
	wa_disp_drv_set_fill(wa_ssd1306_spi_drv_fill);
	wa_disp_drv_set_clear(wa_ssd1306_spi_drv_clear);
	wa_disp_drv_set_update(wa_ssd1306_spi_drv_update);
}
